package ma.android.oook;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class NewLabel extends Activity implements OnClickListener{
	
	private OookDbAdapter mDbHelper;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		 setTitle(getString(R.string.newLabel));
		 setContentView(R.layout.newlabel);
		 
		 Button acceptNewTag = (Button) findViewById(R.id.acceptNewLabel);
		 acceptNewTag.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		EditText tagDescription = (EditText) findViewById(R.id.tagDescription);
	    String description = tagDescription.getText().toString();
	    if (!description.equals(""))
	    {
	    	mDbHelper = new OookDbAdapter(this);
		    mDbHelper.open();
	    	mDbHelper.saveTag(tagDescription.getText().toString());
	    	mDbHelper.close();
	    	Intent intent = getIntent();
			setResult(1, intent);
			finish();
	     }
	}
	

}
